import 'package:FiduMart/core/utils/logger.dart';
import 'package:FiduMart/localization/app_export.dart';

import 'package:FiduMart/screen/webviewtwo/webviewtwo_controller.dart';
import 'package:FiduMart/widget/app_bar/custom_app_bar.dart';
import 'package:flutter/material.dart';
import 'package:FiduMart/screen/webview/web_controller.dart';
import 'package:FiduMart/widget/title_bar.dart';
import 'package:webview_flutter/webview_flutter.dart';


class WebviewTwoScreen extends GetWidget<WebviewTwoController> {

  var title = '';

  @override
  Widget build(BuildContext context) {
    if(title.isEmpty){
      title = Get.parameters['title'] ?? 'mini_details'.tr;
    }
    return Scaffold(
      body: Column(
    children: [
      Column(
      children: [
      SizedBox(height: 30,),
      Row(
        children: [
          SizedBox(width: 20,),
          IconButton(
            icon: Icon(Icons.arrow_back_ios, size: 24,color: Colors.black,),
            onPressed: () {
              if(title == 'mysterious_treasure_box'.tr){
                
              }
              Navigator.pop(context);
            },
          ),
          Expanded(child: Center(child: Text(title, style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)))),
          (title == 'welfare_center'.tr)?Row(
            children: [
              Text('record'.tr,
                style: TextStyle(
                  color: Colors.white, // 文字颜色
                  fontSize: 16, // 文字大小
                ),
              ),
              SizedBox(width: 15,)
            ],
          ):
          SizedBox(width: 70,),
        ],
      ),
      ],
    ),
      Obx(() => controller.loading == true
          ? Expanded(
            child: Center(
                child: CircularProgressIndicator.adaptive(),
              ),
          )
          : Expanded(child: WebViewWidget(controller: controller.wvController))),
    ],
      ),
      // floatingActionButton: favoriteButton(),
    );
  }

  Widget favoriteButton() {
    return FloatingActionButton(
      onPressed: () async {
        final String? url = await controller.wvController.currentUrl();
        Logger.log("Favorited:$url");
      },
      child: const Icon(Icons.favorite),
    );
  }
}
